<template>
    <div class="div02">
        <el-form ref="form" :model="malfunctions" label-width="80px">
  <el-form-item label="房屋编号">
    <el-input v-model="malfunctions.houseId"></el-input>
  </el-form-item>
  <el-form-item label="用户ID">
    <el-input v-model="malfunctions.userId"></el-input>
  </el-form-item>
  <el-form-item label="报修类型">
    <el-select v-model="malfunctions.mtype" placeholder="请选择报修类型">
      <el-option label="家电损坏" value="家电损坏"></el-option>
      <el-option label="房屋装修破损" value="房屋装修破损"></el-option>
    </el-select>
  </el-form-item>
  <el-form-item label="故障描述">
    <el-input type="textarea" v-model="malfunctions.description"></el-input>
  </el-form-item>
  <el-form-item label="是否人为">
    <el-switch v-model="malfunctions.mmade"></el-switch>
  </el-form-item>
    <el-form-item label="房东ID">
    <el-input v-model="malfunctions.ownerId"></el-input>
  </el-form-item>
  <el-form-item label="是否处理">
    <el-switch v-model="malfunctions.handle"></el-switch>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="onSubmit">立即报修</el-button>
    <el-button @click="unSubmit">取消</el-button>
  </el-form-item>
</el-form>
    </div>
</template>
<script>
  export default {
    data() {
      return {
        malfunctions: {
          houseId: '',
          userId: '',
          mtype:'',
          description : '',
          mmade: false,
          ownerId: '',
          handle: false
        }
      }
    },
    methods: {
      onSubmit() {
        this.$refs.form.validate((valid) =>{
        if (valid) {
           this.$axios.put("user/CallforRepairs", this.malfunctions).then((res) => {
            if (res.data.statusCode == 200) {
              this.$router.push('/home');
            } else {
              this.$message.error(res.data.statusMessage);
            }

         });
      }
    });
    },
    unSubmit(){
        this.$router.push('/home');
    }
 } 
}
</script>


<style scoped>
    .div02{
    height:600px;
    width:600px;
    position: fixed;left:400px;top:0px;
    }
</style>